<?php
/**
 * @authors liuqinglin 
 * @email (2961181429@qq.com) 
 * @(https://my.oschina.net/shp32131)
 * @date    2016-11-21 12:55：00
 */

defined('BASEPATH') OR exit('No direct script access allowed');

class System extends Admin_Controller {

	public function __construct()
	{
		parent::__construct();
		$userinfo = $this->session->userinfo;
		if(!isset($userinfo))
		{
			redirect('admin/login'); 
		}
		// $this->output->cache(1/60);
		$this->load->view('templates/header');
		$this->load->view('templates/menu');
	} 
	//系统介绍
	public function index()
	{	
		$this->load->view('system_about');
	}
	//清除缓存 静态页面缓存
	public function clear_cache()
	{
		$directory=APPPATH.'cache';
		$this->delDir($directory);
		$this->load->view('system_about');
	}

	//删除目录方法
	private function delDir($directory) 
	{
		if(file_exists($directory)) 
		{
			if($directory!=APPPATH.'cache')
			{
				rmdir($directory);
			}
			if($dir_handle=@opendir($directory)) 
			{      
				while($filename=readdir($dir_handle)) 
				{  
					if($filename!="." && $filename!=".."&&$filename!='.htaccess'&&$filename!='index.html')
					{   
						$subFile=$directory."/".$filename;
						if(is_dir($subFile))
						{
							$this->delDir($subFile);
						}
						if(is_file($subFile))              
						{
							unlink($subFile);
						}
					}
				}
				closedir($dir_handle);  
			}
		}
	}

}
